<?php
class CardFactory{
	private static $instance = NULL;

	public static function getInstance()
	{
		if(self::$instance == NULL)
		{
			self::$instance = new CardFactory();
		}
		return self::$instance;
	}

	var $cards = array();

	function __construct()
	{
		$xmlDoc = new DOMDocument ();
		$xmlDoc->load (dirname(__FILE__).'/uno_config.xml');
		$cards = $xmlDoc->getElementsByTagName('card');

		foreach ( $cards as $card ) {
			for($i=0;$i<$card->getAttribute("num");$i++)
			array_push($this->cards, $card->getAttribute("id"));
		}
	}

	function getNextCardSet()
	{
		$len = count($this->cards);
		for($i=0;$i<50;$i++){
			$si = rand(0,$len-1);
			$fi = rand(0,$len-1);
			$str = $this->cards[$si];
			$this->cards[$si] = $this->cards[$fi];
			$this->cards[$fi] = $str;
		}
		return $this->cards;
	}
}